Cluster Bootstrapping

This guide for operators who have already installed Argo CD, and have a new cluster and are looking to install many apps in that cluster.

There’s no one particular pattern to solve this problem, e.g. you could write a script to create your apps, or you could even manually create them. However, users of Argo CD tend to use the app of apps pattern.

App Of Apps Pattern

Declaratively specify one Argo CD app that consists only of other apps.

Application of Applications

Helm Example

This example shows how to use Helm to achieve this. You can, of course, use another tool if you like.

A typical layout of your Git repository for this might be:

  1. ├── Chart.yaml
  2. ├── templates
  3. ├── guestbook.yaml
  4. ├── helm-dependency.yaml
  5. ├── helm-guestbook.yaml
  6. └── kustomize-guestbook.yaml
  7. └── values.yaml

Chart.yaml is boiler-plate.

templates contains one file for each child app, roughly:

  1. apiVersion: argoproj.io/v1alpha1
  2. kind: Application
  3. metadata:
  4. name: guestbook
  5. namespace: argocd
  6. finalizers:
  7. - resources-finalizer.argocd.argoproj.io
  8. spec:
  9. destination:
  10. namespace: argocd
  11. server: {{ .Values.spec.destination.server }}
  12. project: default
  13. source:
  14. path: guestbook
  15. repoURL: https://github.com/argoproj/argocd-example-apps
  16. targetRevision: HEAD

The sync policy to automated + prune, so that child apps are automatically created, synced, and deleted when the manifest is changed, but you may wish to disable this. I’ve also added the finalizer, which will ensure that your apps are deleted correctly.

Fix the revision to a specific Git commit SHA to make sure that, even if the child apps repo changes, the app will only change when the parent app change that revision. Alternatively, you can set it to HEAD or a branch name.

As you probably want to override the cluster server, this is a templated values.

values.yaml contains the default values:

  1. spec:
  2. destination:
  3. server: https://kubernetes.default.svc

Next, you need to create and sync your parent app, e.g. via the CLI:

  1. argocd app create apps \
  2. --dest-namespace argocd \
  3. --dest-server https://kubernetes.default.svc \
  4. --repo https://github.com/argoproj/argocd-example-apps.git \
  5. --path apps
  6. argocd app sync apps

The parent app will appear as in-sync but the child apps will be out of sync:

New App Of Apps

You can either sync via the UI, firstly filter by the correct label:

Filter Apps

Then select the “out of sync” apps and sync:

Sync Apps

Or, via the CLI:

  1. argocd app sync -l app.kubernetes.io/instance=apps

View the example on Github.